package util;



public class WordsInRandomSequencesCalculator {

	//private final DoublePair[] shrinkedWords = new DoublePair[8];
	private final DoublePair[] shrinkedWords = new DoublePair[10];

	private final Shuffler shuff = new Shuffler();

	private final int NUMOFTRIALS = 1000;

	public WordsInRandomSequencesCalculator() {
		shrinkedWords[0] = new DoublePair("AAAAAAAAA", 0);
		shrinkedWords[1] = new DoublePair("AAAAAAAAG", 0);
		shrinkedWords[2] = new DoublePair("AAAAAAAGG", 0);
		shrinkedWords[3] = new DoublePair("AAAAAAGGG", 0);
		shrinkedWords[4] = new DoublePair("AAAAAGGGG", 0);
		shrinkedWords[5] = new DoublePair("AAAAGGGGG", 0);
		shrinkedWords[6] = new DoublePair("AAAGGGGGG", 0);
		shrinkedWords[7] = new DoublePair("AAGGGGGGG", 0);
		shrinkedWords[8] = new DoublePair("AGGGGGGGG", 0);
		shrinkedWords[9] = new DoublePair("GGGGGGGGG", 0);
		/*
		shrinkedWords[0] = new DoublePair("AAAAAAA", 0);
		shrinkedWords[1] = new DoublePair("AAAAAAG", 0);
		shrinkedWords[2] = new DoublePair("AAAAAGG", 0);
		shrinkedWords[3] = new DoublePair("AAAAGGG", 0);
		shrinkedWords[4] = new DoublePair("AAAGGGG", 0);
		shrinkedWords[5] = new DoublePair("AAGGGGG", 0);
		shrinkedWords[6] = new DoublePair("AGGGGGG", 0);
		shrinkedWords[7] = new DoublePair("GGGGGGG", 0);*/
	}

	public void addSequenceUpdate(String sequence) {
		String shuffledSequence = "";
		for (int i = 0; i < NUMOFTRIALS; i++) {
			shuffledSequence = shuff.shuffle(sequence);
			for (int j = 0; j < shuffledSequence.length() - 8; j++) {
				String subWord = shuffledSequence.substring(j, j + 9);
				if (subWord.equals("AAAAAAAAA")) {
					shrinkedWords[0].increment();
				}
				if (subWord.equals("AAAAAAAAG")) {
					shrinkedWords[1].increment();
				}
				if (subWord.equals("AAAAAAAGG")) {
					shrinkedWords[2].increment();
				}
				if (subWord.equals("AAAAAAGGG")) {
					shrinkedWords[3].increment();
				}
				if (subWord.equals("AAAAAGGGG")) {
					shrinkedWords[4].increment();
				}
				if (subWord.equals("AAAAGGGGG")) {
					shrinkedWords[5].increment();
				}
				if (subWord.equals("AAAGGGGGG")) {
					shrinkedWords[6].increment();
				}
				if (subWord.equals("AAGGGGGGG")) {
					shrinkedWords[7].increment();
				}
				if (subWord.equals("AGGGGGGGG")) {
					shrinkedWords[8].increment();
				}
				if (subWord.equals("GGGGGGGGG")) {
					shrinkedWords[9].increment();
				}

			}
		}
	}

	public void printWords() {
		for (int i = 0; i < 10; i++) {
			shrinkedWords[i].setNumber(shrinkedWords[i].getNumber()
					/ NUMOFTRIALS);
		}
		for (int i = 0; i < 10; i++) {
			System.out.println(shrinkedWords[i]);
		}
	}

}
